package com.zhixue.content.feignclient;

import com.zhixue.content.po.CourseIndex;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author Dragon
 * @description SearchServiceClientFallbackFactory
 * @date 2023/10/12 14:54
 */
@Slf4j
@Component
public class SearchServiceClientFallbackFactory implements FallbackFactory<SearchServiceClient> {
    @Override
    public SearchServiceClient create(Throwable throwable) {
        return new SearchServiceClient() {
            @Override
            public Boolean add(CourseIndex courseIndex) {
                log.debug("添加课程索引发生熔断，索引信息为:{} ， 熔断异常为: {}",courseIndex, throwable.toString(),throwable);
                //走降级，返回fasle
                return false;
            }
        };
    }
}
